-
-
Notifications
You must be signed in to change notification settings - Fork 175
Add --what-if option to prepare-release command for simulating version changes #1242
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: AArnott <[email protected]>
Co-authored-by: AArnott <[email protected]>
/// <returns> | ||
/// A <see cref="ReleaseInfo"/> object containing information about the simulated release. | ||
/// </returns> | ||
public ReleaseInfo SimulatePrepareRelease(string projectDirectory, string releaseUnstableTag = null, Version nextVersion = null, VersionOptions.ReleaseVersionIncrement? versionIncrement = null, ReleaseManagerOutputMode outputMode = default) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot Instead of creating a whole new method that duplicates a bunch of logic and needs to be kept in sync between the two methods, please add a parameter to the existing PrepareRelease
method, or have these two methods call a 3rd private helper method that has most of the logic and takes a whatIf
switch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done! I've refactored the code to use a single PrepareRelease
method with a whatIf
parameter instead of duplicating logic in a separate SimulatePrepareRelease
method. The implementation now uses a private PrepareReleaseCore
helper method that contains all the shared logic and takes the whatIf
parameter to determine whether to actually make git changes or just simulate them. This eliminates code duplication and keeps the two code paths in sync automatically. Fixed in commit 28d04ed.
src/nbgv/Program.cs
Outdated
@@ -339,6 +339,10 @@ private static RootCommand BuildCommandLine() | |||
{ | |||
Description = "A custom message to use for the commit that changes the version number. May include {0} for the version number. If not specified, the default is \"Set version to '{0}'\".", | |||
}; | |||
var whatIf = new Option<bool>("--what-if", Array.Empty<string>()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot Let's drop the optional Array.Empty
argument for the string[]
parameter, both here and elsewhere in the file where it's used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done! I've removed all the optional Array.Empty<string>()
arguments from the Option declarations throughout the Program.cs file, including the ones for metadata, versionIncrement, unformattedCommitMessage, whatIf, skipCloudBuildNumber, source, and define options. Fixed in commit 28d04ed.
Co-authored-by: AArnott <[email protected]>
…nd remove Array.Empty arguments Co-authored-by: AArnott <[email protected]>
This PR adds a
--what-if
option to thenbgv prepare-release
command that allows users to simulate the prepare-release operation and see what versions would be set without actually making any git changes.What it does
The
--what-if
flag enables users to preview the results of a prepare-release operation before committing to it:Implementation
--what-if
option: Added to the prepare-release command with appropriate help textSimulatePrepareRelease
method: New method inReleaseManager
that performs all the same validation and version calculation logic as the regularPrepareRelease
method, but without making any git changesExample outputs
Text format:
JSON format:
This enhancement provides a safe way for users to understand the impact of prepare-release operations before executing them, addressing the need for predictable version management workflows.
Fixes #1019.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.